package pacBiopackage;


import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class PacBioSNPLineReader implements PacBioReader {
	
	
	protected RandomAccessFile rac = null;
	
	public PacBioSNPLineReader(String filename) throws FileNotFoundException 
	{
		File file = new File(filename);
		rac = new RandomAccessFile(file,"r");
	}

	
	
	public boolean ready() throws IOException
	{
		//return br.ready();
		if(rac.getFilePointer() < rac.length())
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	
	public List<String> next() throws IOException
	{
		StringTokenizer st = new StringTokenizer(rac.readLine()," \t");
		List<String> output = new ArrayList<String>();
		while(st.hasMoreTokens())
		{
			output.add(st.nextToken());
		}
		return output;
	}
	
	public void setFilePosition(long pos) throws IOException
	{
		rac.seek(pos);
	}
	
	public long getFilePosition() throws IOException
	{
		return rac.getFilePointer();
	}
	
	public boolean close()
	{
		try
		{
			rac.close();
			return true;
		}
		catch(Exception e)
		{
			e.printStackTrace();
			return false;
		}
	}

}
